package com.meituan.controller;

import com.meituan.pojo.req.PermissionReq;
import com.meituan.pojo.resp.BaseResp;
import com.meituan.service.PermissionService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/permission")
public class PermissionController {
    @Autowired
    PermissionService permissionService;

//    @RequiresPermissions(value ={"permission_findAll"})
    @PostMapping("/findAll")
    public BaseResp findAll(){
        return permissionService.findAll();
    }

//    @RequiresPermissions(value ={"permission_delete"})
    @PostMapping("/deleteById")
    public BaseResp deleteById(@RequestBody Map map){
        return permissionService.deleteById(Integer.parseInt(map.get("id").toString()));
    }

//    @RequiresPermissions(value ={"permission_update"})
    @PostMapping("/saveOrUpdate")
    public BaseResp saveOrUpdate(@RequestBody PermissionReq permissionReq){
        return permissionService.saveOrUpdate(permissionReq);

    }
}
